/*
 *  AObject.cpp
 *  libavid
 *
 *  Created by Peter on 23.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#include "AObject.h"

#include <sstream>

void writePcidToStream( std::ostream& str, AObject::PCID pcid )
{
	union
	{
		AObject::PCID fourcc;
		char          c[ 4 ];
	} u;
	
	u.fourcc = pcid;
	
#ifdef TR_BIG_ENDIAN
	str << u.c[ 0 ] << u.c[ 1 ] << u.c[ 2 ] << u.c[ 3 ];
#else
	str << u.c[ 3 ] << u.c[ 2 ] << u.c[ 1 ] << u.c[ 0 ];
#endif
}	

std::string pcidToString( AObject::PCID pcid )
{
	std::stringstream str;
	
	writePcidToStream( str, pcid );
	
	return str.str();
}

AObject::PCID AObject::getClassId() const
{
	// No idea which PCID AObject is supposed to have
	return '????';
}

std::string AObject::getClassName() const
{
	return "AObject";
}

bool AObject::isInstanceOf( const std::string& className ) const
{
	// Derived classes check if className is their own name, then recursively
	// dispatch to the base class. We are the root, so if this gets called an
	// the requested class name is not "AObject", then we are not an instance of
	// the given class.
	return className == "AObject";
}

void AObject::readFromStream( AStream& str, const AObjDoc& objd )
{
	// Nothing to do here
}

void AObject::writeToStream( AStream& str ) const
{
	// Nothing to do here
}

void AObject::dump( std::ostream& str ) const
{
	// We may want to write something here, but nothing for now.
}